#ifndef YOOHOO_XMPPCORE_RESOURCEBINDINGNEGOTIANT_H
#define YOOHOO_XMPPCORE_RESOURCEBINDINGNEGOTIANT_H

#include "xmppcore/negotiant.h"
#include "xmppcore/xmppparsingfactory.h"
#include "xmppcore/protocoltranslator.h"

namespace yoohoo_xmppcore {

class ResourceBindingParsingFactory : public XmppParsingFactory {
public:
	ResourceBindingParsingFactory();
};

class Jid : public XmppObject, public ProtocolTranslator {
public:
	static const ProtocolKey PROTOCOL_KEY;
	Jid(QString jid);
	Jid(Jid& other);
	QString jid();
	QString toXml();

private:
	QString _jid;
};

class JidParser : public XmppParser {
public:
	JidParser();
	XmppObject* obj();
	bool processAttributes(QString path, QList<ParsingAttribute> attributes);
	virtual bool processText(QString path, QString text);

private:
	Jid* _jid;
};

class JidParserFactory : public XmppParserFactory {
public:
	ProtocolKey protocolKey();
	XmppParser* createParser();
};

class ResourceBindingNegotiant : public Negotiant {
	Q_OBJECT
public:
	enum ResourceBindingError {
		ConflictError,
		NotAllowedError,
		ForbiddenError
	};
	ResourceBindingNegotiant(Connector* connector, QString resource = QString(), QObject* parent = 0);
	void negotiate();

signals:
	void success(QString jid);
	void resourceBindingError(ResourceBindingError error);

protected slots:
	void connectorReceived(QString xml);

private:
	XmppParsingFactory* parsingFactory() const;

private:
	QString _resource;
	QString _id;
};

}

#endif
